<?php
# 连接Web服务器
//获取服务器
$host = $_SERVER['SERVEWR_NAME'];
$port = $_SERVER['SERVER_PORT'];

// 建立连接
$socket = fsockopen($host, $port, $errno, $errstr);

$request = <<<EOD
GET /index.php HTTP/1.1
Host: $host
Connection: Close
EOD;

// 发送请求
fwrite($socket, $request);

// 读取响应
while (!feof($socket)) {
    echo fgets($socket);
}

fclose($socket);